package com.ch.base.dao;

import com.ch.base.model.ChBasicOrderModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ch_basic_order dao
 * created in 2019-04-19 10:39
 **/
@Mapper
public interface ChBasicOrderModelData {

    @Insert({"<script>",
            "insert into ch_basic_order(id,order_id,order_time,receiver_name,receiver_phone,receiver_address,province," +
                    "city,district,item_name,item_specification,purchase_num,order_money,order_note,order_status,state," +
                    "created_time,updated_time,operator_name) values ",
            "<foreach collection = 'list' item = 'item' index = 'index' separator = ','>",
            "(#{item.id},#{item.orderId},#{item.orderTime},#{item.receiverName},#{item.receiverPhone},#{item.receiverAddress},#{item.province}," +
                    "#{item.city},#{item.district},#{item.itemName},#{item.itemSpecification},#{item.purchaseNum},#{item.orderMoney},#{item.orderNote},#{item.orderStatus},'1'," +
                    "NOW(),#{item.updatedTime},#{item.operatorName})",
            "</foreach>",
            "</script>"})
    @Options(useGeneratedKeys = true)
    int batchInsertOrders(@Param("list") List<ChBasicOrderModel> list);


    @SelectProvider(type = ChBasicOrderModelProvider.class, method = "findCountByCondition")
    int findCountByCondition(ChBasicOrderModel entity);


    @SelectProvider(type = ChBasicOrderModelProvider.class, method = "findOrdersByCondition")
    List<ChBasicOrderModel> findOrdersByCondition(ChBasicOrderModel entity);
}
